
// Module
module Utilities {
    
    export function removeFirst(array: Array, match: (candidate: any) => bool) { 
        for (var index: number = 0; index < array.length; ++index){
            var candidate = array[index];
            if (match(candidate)) {
                array.splice(index, 1);
                break;
            }
        }
    }

    export function count(array: Array, match: (candidate: any) => bool) {
        var count: number = 0;
        for (var index: number = 0; index < array.length; ++index) {
            var candidate = array[index];
            if (match(candidate)) {
                ++count;
            }
        }
        return count;
    }
}

